<tagLib name="strends" />
<include file="Public:header" />
<div class="handle-btns">
	<strends:linkBtn text="{%RETURN_LIST}" href="{:U(MODULE_NAME.'/index')}" />
</div>
<form method='post' id="form" name="form" action="{:U(MODULE_NAME.'/update')}">
<table cellpadding="4" cellspacing="0" border="0" class="table-form">
	<tr>
		<th width="200">{%MID}</th>
		<td>
			<select name='mid' id='mid' >
				<volist name="admin" id="vo" >
					<option value='{$vo.uid}'>{$vo.user_name}</option>
				</volist>
				<volist name="hou" id="vo" >
					<option value='{$vo.id}'>{$vo.admin_name}</option>
				</volist>
			</select>
		</td>
	</tr>
	<input type='hidden'  id='redis' name='redis' value='{$RoleDetail[0].from}'/>
	<tr>
		<th width="200">{%shenfen}</th>
		<td>
			<select  name='type' id='type'>
				<volist name="role" id="vs">
					<if condition="$vs.have eq  1">
					<option value='{$vs.id}' selected>{$vs.name}</option>
					<else />
					<option value='{$vs.id}' >{$vs.name}</option>
					</if>
				</volist>
			</select>
		</td>
	</tr>
	<script>
		$(function (){
			$('#type').change(function (){
				var mid=$('#mid').attr('value');
				var redis=$('#redis').attr('value');
				var type=$(this).attr('value');
				var da="";
				if(mid){
					 da+='mid=1&';
				}
				if(redis){
					 da+='redis='+redis+'&';
				}
				if(type){
					da+='type='+type;
				}
				$.ajax({
					url: APP + '?' + VAR_MODULE + '=RoleDetail&' + VAR_ACTION + '=edit_type',
					type:"POST",
					cache: false,
					data:da,
					dataType:"json",
					success: function(result){
						var home=result.res[0].length;
						var auto=result.res[1].length;
						var fashion=result.res[2].length;
						$('#home').html('');
						$('#auto').html('');
						$('#fashion').html('');
						for(var i=0;i<home;i++){
							if(result.res[0][i].have==0){
								$('#home').append('<label><input class="action-item" type="checkbox" name="uid[]" value="'+result.res[0][i].uid+'"  /><span>&nbsp;'+result.res[0][i].user_name+'</span></label>&nbsp;&nbsp;&nbsp;');
							}else{
								$('#home').append('<label><input class="action-item" type="checkbox" name="uid[]" value="'+result.res[0][i].uid+'" checked  /><span>&nbsp;'+result.res[0][i].user_name+'</span></label>&nbsp;&nbsp;&nbsp;');
							}
						}
						
						for(var j=0;j<auto;j++){
							if(result.res[1][j].have==0){
								$('#auto').append('<label><input class="action-item" type="checkbox" name="uid[]" value="'+result.res[1][j].uid+'"  /><span>&nbsp;'+result.res[1][j].user_name+'</span></label>&nbsp;&nbsp;&nbsp;');
							}else{
								$('#auto').append('<label><input class="action-item" type="checkbox" name="uid[]" value="'+result.res[1][j].uid+'" checked  /><span>&nbsp;'+result.res[1][j].user_name+'</span></label>&nbsp;&nbsp;&nbsp;');
							}
						}
						
						for(var g=0;g<fashion;g++){
							if(result.res[2][g].have==0){
								$('#fashion').append('<label><input class="action-item" type="checkbox" name="uid[]" value="'+result.res[2][g].uid+'"  /><span>&nbsp;'+result.res[2][g].user_name+'</span></label>&nbsp;&nbsp;&nbsp;');
							}else{
								$('#fashion').append('<label><input class="action-item" type="checkbox" name="uid[]" value="'+result.res[2][g].uid+'" checked  /><span>&nbsp;'+result.res[2][g].user_name+'</span></label>&nbsp;&nbsp;&nbsp;');
							}
						}
					}
				});
			});
		})
		
	</script>
	
	<tr>
		<th width="200">{%FASHION}</th>
		<td>
			<p id="fashion" >
				<volist name="fashion" id="vu">
					<if condition="$vu.is_have eq 1 " > 
					<label><input class="action-item" type="checkbox" name="uid[]" value="{$vu.uid}" checked /><span>&nbsp;{$vu.user_name}</span></label>&nbsp;&nbsp;
					<else />
					<label><input class="action-item" type="checkbox" name="uid[]" value="{$vu.uid}"  /><span>&nbsp;{$vu.user_name}</span></label>&nbsp;&nbsp;
					</if>
				</volist>
			</p>
		</td>
	</tr>
	
	<tr class="act">
		<th>&nbsp;</th>
		<td>
			<input type="submit" class="submit_btn" value="{%SUBMIT}" />
			<input type="reset" class="reset_btn" value="{%RESET}" />
		</td>
	</tr>
</table>
</form>
<include file="Public:footer" />